package com.csxy.six.controller;

import com.csxy.six.entity.Club;
import com.csxy.six.service.ClubService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/club")
@Tag(name = "社团管理", description = "社团信息管理接口")
public class ClubController {

    @Autowired
    private ClubService clubService;

    @Operation(summary = "获取所有社团", description = "返回系统中所有社团的列表")
    @GetMapping
    public List<Club> getAllClubs() {
        return clubService.list();
    }

    @Operation(summary = "创建社团", description = "创建一个新的社团")
    @PostMapping
    public boolean createClub(@RequestBody Club club) {
        return clubService.save(club);
    }

    @Operation(summary = "更新社团", description = "更新指定ID的社团信息")
    @PutMapping("/{id}")
    public boolean updateClub(@PathVariable Long id, @RequestBody Club club) {
        club.setId(id);
        return clubService.updateById(club);
    }

    @Operation(summary = "删除社团", description = "删除指定ID的社团")
    @DeleteMapping("/{id}")
    public boolean deleteClub(@PathVariable Long id) {
        return clubService.removeById(id);
    }
}